from pydantic import BaseModel, Field, model_validator
from typing import List
from typing_extensions import Self
from dis_qa.config import get_distilabel_config

def get_system_prompt():
    max_qa = get_distilabel_config().MAX_GOLDENS_PER_CONTEXT
    return f"""You are a helpful assistant that extracts question-answer pairs from a technical document.
For the given document fragment, produce a JSON list of question/answer pairs in the format:
[
  {{"question": "...", "answer": "..."}},
  ...
]

Generate {max_qa} concise question-answer pairs about the document.

Make sure each question is answerable from the snippet and answers are concise.
"""


# 定义 Q&A 数据结构
class QAPair(BaseModel):
    question: str = Field(..., description="Generated question")
    answer: str = Field(..., description="Answer to the question")

    # @model_validator(mode="after")
    # def validate_model(self):
    #     # 错误：返回了非 self 的值
    #     return self


class QADoc(BaseModel):
    qas: List[QAPair]

    # @model_validator(mode="after")
    # def validate_model(self):
    #     # 错误：返回了非 self 的值
    #     return self